package com.hice.demo.java.concurrent.arrayblockingqueue;

import java.util.concurrent.BlockingQueue;

/**
 * Consumer类,它只是把对象从队列中抽取出来，然后将它们打印到 System.out。
 * @author hyson
 * @create 2017-03-13 10:14
 */
public class Consumer implements Runnable {

    protected BlockingQueue queue = null;

    public Consumer(BlockingQueue queue) {
        this.queue = queue;
    }

    public void run() {
        try {
            System.out.println(queue.take());
            System.out.println(queue.take());
            System.out.println(queue.take());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
